<%@page import="weaver.conn.RecordSet"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="com.zlgs.cqyf.vote.ConnectionUtil"%>
<%@ page import="java.io.PrintWriter" %>
<%
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json; charset=utf-8");
    JSONObject retObject = new JSONObject();
	retObject.put("code", 200);
	retObject.put("msg", "操作成功");
	try{
    	// URL 参数
	    Object id  = request.getParameter("id");                   // 奖项配置ID
	    Object name  = request.getParameter("name");               // 奖项配置名称
	    Object startTime  = request.getParameter("startTime");    // 开始时间
	    Object endTime  = request.getParameter("endTime");        // 结束时间
	    Object dateType  = request.getParameter("dateType");      // 时间类型：1 年度 2 季度
	    Object about  = request.getParameter("about");             // 活动介绍/活动规则等信息（html格式保存）
	    Object regular  = request.getParameter("regular");               // 活动介绍/活动规则等信息（html格式保存）
	    Object votes  = request.getParameter("votes");             // 投票规则：活动每人N票
	    Object votesSame  = request.getParameter("votesSame");    // 投票规则：同一个人允许投N票
	
	    // 跟新数据
	    String sql = "update vote_awards set " +
	                    "name=N'"+name+"', " +
	                    "start_time='"+startTime+"', " +
	                    "end_time='"+endTime+"'," +
	                    "date_type="+dateType+", " +
	                    "about=N'"+about+"', " +
	                    "regular=N'"+regular+"', " +
	                    "votes="+votes+", " +
	                    "votes_same="+votesSame+", " +
	                    "update_time=GETDATE() where id="+id;
	  RecordSet set = new RecordSet();
	  set.executeSql(sql);
	} catch (Exception e) {
        e.printStackTrace();
        retObject.put("code", -1);
        retObject.put("msg", e.getMessage());
    } finally {
		PrintWriter printWriter  = response.getWriter();
		printWriter.append(retObject.toJSONString());
        if (printWriter != null) printWriter.close();
    }
%>
